﻿using Sirenix.OdinInspector;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

namespace TowerDefence_Zombie
{

    [Serializable]
    public class ItemSiginUIInfo
    {
        [SerializeField, Title("字体材质")] public Material fontMaterial;
        [SerializeField, Title("背景")] public Sprite Bg;
        [SerializeField, Title("奖励背景")] public Sprite rewardBg;
    }
    public class ItemSigin : MonoBehaviour
    {
        [SerializeField,Title("签到天数")] public TextMeshProUGUI dayText;
        [SerializeField,Title("签到奖励")] public TextMeshProUGUI rewardText;
        [SerializeField,Title("签到背景")] public Image Bg;
        [SerializeField, Title("签到奖励背景")] public Image rewardBg_2;

        [SerializeField, Title("签到奖励Icon")] public Image rewardIcon;

        [SerializeField,Title("已签到")] public Transform signed;

        [SerializeField,Title("金币UIinfo")] public ItemSiginUIInfo goldUIInfo;
        [SerializeField,Title("其他UIinfo")] public ItemSiginUIInfo otherUIInfo;

        public void SetSignInfo(SiginRewardData siginRewardData)
        {
            if(siginRewardData.MoneyId == 101)
            {
                dayText.material = goldUIInfo.fontMaterial;
                rewardText.material = goldUIInfo.fontMaterial;
                Bg.sprite = goldUIInfo.Bg;
                rewardBg_2.sprite = goldUIInfo.rewardBg;
            }
            else
            {
                dayText.material = otherUIInfo.fontMaterial;
                rewardText.material = otherUIInfo.fontMaterial;
                Bg.sprite = otherUIInfo.Bg;
                rewardBg_2.sprite = otherUIInfo.rewardBg;
            }
            rewardText.text = siginRewardData.MoneyNum.ToString();
            if (siginRewardData.MoneyId == 101)
                rewardIcon.GetComponent<RectTransform>().sizeDelta = new Vector2(120, 120);
            else if(siginRewardData.MoneyId == 102)
                rewardIcon.GetComponent<RectTransform>().sizeDelta = new Vector2(160, 136);
            else if(siginRewardData.MoneyId == 103)
                rewardIcon.GetComponent<RectTransform>().sizeDelta = new Vector2(120, 120);


            rewardIcon.sprite = Resources.Load<Sprite>(siginRewardData.MoneyIconRes);
        }

        public void SetSigned()
        {
            signed.gameObject.SetActive(true);
        }
    }
}
